import {Injectable} from '@angular/core';
import {Menu} from '../models/menu';
import {MENUS} from '../../../mock/base/menu';

@Injectable()
export class MenuService {

  constructor() {
  }

  getMenu(id: string): Promise<Menu> {
    return this.getMenus()
      .then(heroes => heroes.find(hero => hero.id === id));
  }

  getMenus(): Promise<Menu[]> {
    return Promise.resolve(MENUS);
  }

  getHeroesSlowly(): Promise<Menu[]> {
    return new Promise(resolve => {
      // Simulate server latency with 2 second delay
      setTimeout(() => resolve(this.getMenus()), 2000);
    });
  }

}
